package CtrlLayer;

import ModelLayer.*;
import java.util.ArrayList;

/**
 * Write a description of class ProductController here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class ProductController
{
    private ProductContainer productContainer;
    private Product product;
    private SalesLine saleLine;

    /**
     * Constructor for objects of class ProductController
     */
    public ProductController()
    {
        productContainer = ProductContainer.getInstance();
    }
    
    public boolean addProduct(Product product)
    {
        return productContainer.addProduct(product);
    }
    
    public void updateProduct (int barCode, String name, double price, double weight, String location)
    {
        findProductByBarCode(barCode).setProductName(name);
        findProductByBarCode(barCode).setPrice(price);
        findProductByBarCode(barCode).setWeight(weight);
        findProductByBarCode(barCode).setLocation(location);
        //         findProductByBarCode(barCode).setQuantity(quantity);
    }
    
    public boolean updateQuantity (int barCode, int amount)
    {
        return findProductByBarCode(barCode).increaseQuantity(amount);
    }
    
    public Product findProductByBarCode(int barcode)
    {
        return productContainer.findProductByBarCode(barcode);
    }
    
    public Product findProductByName(String name)
    {
        return productContainer.findProductByName(name);
    }
    
    public boolean deleteProductByBarCode(int barcode)
    {
        return productContainer.deleteProductByBarCode(barcode);
    }
}
